package org.spamforces.web.frame;

import org.nocturne.main.ApplicationContext;
import org.nocturne.main.Page;
import org.nocturne.util.StringUtil;
import org.spamforces.web.page.WebPage;

/**
 * @author Mike Mirzayanov
 */
public class MessageBox extends ApplicationFrame {
    @Override
    public void action() {
        if (getRequest().isRequestedSessionIdValid()) {
            String message = getSession("message", String.class);

            Page page = ApplicationContext.getInstance().getCurrentPage();
            if (!StringUtil.isEmptyOrNull(message) && page instanceof WebPage) {
                removeSession("message");
                put("message", message);
            }
        }
    }
}
